package com.bookcloud.java21.chapter2.数据类型_字符文本块2_6;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

/** 2.6 数据类型—字符文本块 */
public class Lesson26 {
  public static void main(String[] args) throws UnsupportedEncodingException {
    String html = "<html>" + "<h2>hello world! </h2>" + "</html>";
    System.out.println("传统的html:" + html);
    String blockText =
        """
        <html>
            <h2>hello world! </h2>
        </html>
    """;
    System.out.println("blockText:/n" + blockText);
    // 转换成bytes存储，utf-8
    byte[] data = blockText.getBytes("utf-8");
    System.out.println("data:" + data);
    // 转换成字符
    String dataStr = new String(data, StandardCharsets.UTF_8);
    System.out.println("dataStr:" + dataStr);
  }
}
